<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MVCWeb.Models.EventPictureGallery>>" %>

<%@ Register Src="~/Views/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="mmuc" %>

<%@ Register Src="~/Views/Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="louc" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
	<title>ManageGallery</title>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <script language="javascript" type="text/javascript">
        function deleteRecord(recordId) {
            if (confirm("Are you sure to delete this picture ?")) {
                // Perform delete
                var action = '<%= Url.Action("DeletePicture", "Event") %>/' + recordId;
                var request = new Sys.Net.WebRequest();
                request.set_httpVerb("POST");
                request.set_url(action);
                request.add_completed(deleteCompleted);
                request.invoke();
            }
        }

        function deleteCompleted() {
            // Reload page  
            window.location.reload();
        }    
    </script>
    
    <louc:LogOnUserControl ID="LogOnUserControl1" runat="server" />
    <!-- BEGIN: MainMenu -->
    <mmuc:MainMenu ID="MainMenu1" runat="server" />
    <!-- END: MainMenu -->
    
    <h2>ManageGallery</h2>

    <table>
        <tr>
            <th></th>
            <th>
                Id
            </th>            
            <th>
                Caption
            </th>
            <th>
                Thumbnails
            </th>
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr>
            <td>
                <%= Html.ActionLink("Edit", "EditPicture", new { id=item.GalleryId  }) %> |
                <a onclick="deleteRecord(<%= item.GalleryId %>)" href="JavaScript:void(0)">Delete </a>
            </td>
            <td>
                <%= Html.Encode(item.GalleryId) %>
            </td>                        
            <td>
                <%= Html.Encode(item.Caption) %>
            </td>
            <td>
                <img src='<%= Html.Encode(item.ThumbnailPath) %>' alt="" width="60px" height="50px" />
            </td>
        </tr>
    
    <% } %>

    </table>

    <p>
        <%= Html.ActionLink("Create New", "CreatePicture", new { id = ViewData["EventId"] })%>
    </p>

</asp:Content>

